﻿// -----------------------------------------------------------------------
// Copyright (c) David Kean. All rights reserved.
// -----------------------------------------------------------------------
extern alias pcl;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using pcl::System.Security.Cryptography;

namespace Portable.Security.Cryptography
{
    [TestClass]
    public class CryptographicExceptionTests
    {
        [TestMethod]
        public void Constructor1_SetsMessagePropertyToDefault()
        {
            var exception = new CryptographicException();

            Assert.IsNotNull(exception.Message);
        }

        [TestMethod]
        public void Constructor1_SetsInnerExceptionPropertyToNull()
        {
            var exception = new CryptographicException();

            Assert.IsNull(exception.InnerException);
        }

        [TestMethod]
        public void Constructor2_NullAsMessage_SetsMessagePropertyToDefault()
        {
            var exception = new CryptographicException((string)null);

            Assert.IsNotNull(exception.Message);
        }

        [TestMethod]
        public void Constructor2_ValueAsMessage_SetsMessageProperty()
        {
            var exception = new CryptographicException("Message");

            Assert.AreEqual("Message", exception.Message);
        }

        [TestMethod]
        public void Constructor2_SetsInnerExceptionToNull()
        {
            var exception = new CryptographicException((string)null);

            Assert.IsNull(exception.InnerException);
        }

        [TestMethod]
        public void Constructor3_NullAsMessage_SetsMessagePropertyToDefault()
        {
            var exception = new CryptographicException((string)null, (Exception)null);

            Assert.IsNotNull(exception.Message);
        }

        [TestMethod]
        public void Constructor3_ValueAsMessage_SetsMessageProperty()
        {
            var exception = new CryptographicException("Message", (Exception)null);

            Assert.AreEqual("Message", exception.Message);
        }

        [TestMethod]
        public void Constructor3_NullAsInner_SetsInnerExceptionToNull()
        {
            var exception = new CryptographicException((string)null, (Exception)null);

            Assert.IsNull(exception.InnerException);
        }

        [TestMethod]
        public void Constructor3_ValueAsInner_SetsInnerExceptionToNull()
        {
            var inner = new Exception();
            var exception = new CryptographicException((string)null, inner);

            Assert.AreSame(inner, exception.InnerException);
        }
    }
}
